package com.xy.biz.mes.domain.bo;

import com.xy.biz.rs.domain.resp.GetRecordTemplateGroupResponse;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 *
 *
 * @author zsp
 * @date 2022-1-20
 */
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class ManufactureTaskBO {

    /**
     * 生产任务Id
     */
    private Long manufactureTaskId;
    /**
     * 生产任务编号
     */
    private String manufactureTaskCode;
    /**
     * 生产订单Id
     */
    private Long manufactureOrderId;
    /**
     * 生产订单编号
     */
    private String manufactureOrderCode;
    /**
     * 订单类型：1-分装，2-生产
     */
    private Integer orderType;
    /**
     * 生产记录模板Id
     */
    private Long recordTemplateId;
    /**
     * 生产记录模板名称
     */
    private String recordTemplateName;
    /**
     * 生产人用户Id
     */
    private Long manufactureUserId;
    /**
     * 生产人用户姓名
     */
    private String manufactureUserName;
    /**
     * 备注
     */
    private String memo;
    /**
     * 租户Id，0表示不指定
     */
    private Long tenantId;
    /**
     * 状态：0-已取消，10-待生产，20-开始生产，30-已记录，40-已核查
     */
    private Integer status;
    /**
     * 创建人Id
     */
    private Long createUserId;
    /**
     * 创建人用户姓名
     */
    private String createUserName;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
    /**
     * 生产时间
     */
    private LocalDateTime manufactureTime;
    /**
     * 记录时间
     */
    private LocalDateTime recordTime;
    /**
     * 核查人用户Id
     */
    private Long reviewUserId;
    /**
     * 核查人用户名
     */
    private String reviewUserName;
    /**
     * 核查时间
     */
    private LocalDateTime reviewTime;
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 生产订单
     */
    private ManufactureOrderBO manufactureOrder;
    /**
     * 货品明细
     */
    private List<ManufactureTaskGoodsBO> goodsList;
    /**
     * 记录明细
     */
    private List<ManufactureTaskRecordBO> recordList;
    /**
     * 设备明细
     */
    private List<ManufactureTaskEquipmentBO> equipmentList;
    /**
     * 记录模板组
     */
    List<GetRecordTemplateGroupResponse> recordTemplateGroupList;

    public ManufactureTaskBO addGoods(List<ManufactureTaskGoodsBO> manufactureOrderGoodsBOList) {
        if (CollectionUtils.isEmpty(goodsList)) {
            goodsList = new ArrayList<>();
        }
        goodsList.addAll(manufactureOrderGoodsBOList);
        return this;
    }

    public ManufactureTaskBO addEquipment(List<ManufactureTaskEquipmentBO> manufactureTaskEquipmentBOList) {
        if (CollectionUtils.isEmpty(equipmentList)) {
            equipmentList = new ArrayList<>();
        }
        equipmentList.addAll(manufactureTaskEquipmentBOList);
        return this;
    }
}
